const enterpriseVue = new Vue({
    el: '#app',
    data() {
      return {
        form: {//提交的表单
          Enterprise_Info_SerialNumber: '',//主键
          Picture_URL: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
          Enterprise_Name: "",//企业名称
          Industry_SubCategory_SerialNumber: "101000000000001",
          Industry_Category_SerialNumber: "100000000000001",
          Enterprise_Address: '',//企业注册地址
          Postal_Code: '',//邮政编号
          Tax_Number: '',//营业执照注册号
          Tax_Registration_Number: '',//税务登记证号
          Organization_Code_Certificate_Number: '',//组织机构代码证号
          Enterprise_Phone: '',//企业电话
          Enterprise_Contacts: '',//企业联系人
          Enterprise_Contacts_Mobile: '',//企业手机号
          E_Mail: '',//电子邮箱
          Children: {
            enterprise_legal_person: [{
              Enterprise_Legal_Person_SerialNumber: "",
              Enterprise_Info_SerialNumoer: "",
              Legal_Person: '',//法人姓名
              ID_Number: '',//法人身份证号
              Mobile: '',//法人手机号
            }],
            enterprise_account: [{
              Enterprise_Account_SerialNumber: "",
              Enterprise_Info_SerialNumoer: "",
              Bank_Name: '',//开户行
              Account_Number: '',//银行账号
            }]
          }
        },
        loading:false,
        form1:{
          Enterprise_Account_SerialNumber:"",
          Enterprise_Info_SerialNumber:$.cookie("enterprise"),
          Account_Name:"",
          Account_Number:"",
          Bank_Name:"",
        },
        label: " ",
        sales_order_logistics: [{
          Sales_Order_Logistics_SerialNumber: '', //主键
          Sales_Order_SerialNumber: '啊啊啊',   //账户名称
          LogisticsNumbers: '155161616',  //开户银行
          LogisticsCode: '625494899546',  //银行账户
        },
        {
          Sales_Order_Logistics_SerialNumber: '', //主键
          Sales_Order_SerialNumber: '啵啵啵',   //账户名称
          LogisticsNumbers: '155161616',  //开户银行
          LogisticsCode: '625494899546',  //银行账户
        }
        ],
        OddNumbers: false, // 控制驳回弹窗的显示与隐藏
        rejectReason: '', // 驳回理由
        loading: false,
        dialogVisible: false,
        dialogImageUrl: '',
      }
    },
    mounted() {
      const Enterprise_Info_SerialNumber = sessionStorage.getItem('Enterprise_Info_SerialNumber')
      this.getEnterpriseData(Enterprise_Info_SerialNumber)
    },
    computed: {
  
    },
    methods: {
      getEnterpriseData(Enterprise_Info_SerialNumber) {
        var _this = this
        let obj = {
          // 采购信息表
          enterprise_info: {
            enterprise_legal_person : {}
          }
        }
        $.ajax({
          url: DomainName + '/getSubtableInquiryOriginal',
          type: 'POST',
          data: {
            Primary_Key: Enterprise_Info_SerialNumber,
            JSONObject: JSON.stringify(obj),
            token: $.cookie("token")
          },
          success: function (result) {
            _this.form = result.enterprise_info[0]
            console.log(_this.form)
            _this.form.Picture_URL = "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
          },
          error: function (params) {
            console.log(params);
          },
        })
      },
      uploadFront(file) {
        let _this = this
        let num = 1
        if (file.size > 150000 && file.size < 500000) {
          num = 0.4
        } else if (file.size > 500000) {
          num = 0.2
        }
        new Compressor(file, {
          quality: num,
          // if(file.size) {
          // }
          success(file) {
            console.log(file.size)
            const formData = new FormData();
            formData.append('file', file, file.name);
            let oFileReader = new FileReader();
            oFileReader.readAsDataURL(file);
            oFileReader.onload = function (e) {
              $.ajax({
                type: 'POST',
                url: DomainName + '/FileList',
                data: {
                  Data: e.target.result,
                  DataLength: file.size,
                  FileName: file.name
                },
                complete: function (XMLHttpRequest) {
                  _this.loading = false
                  if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                    window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
                  }
                },
                success: function (Result) {
                  _this.tableData1.Picture_URL = e.target.result
                  if (Result.Status == "success") {
                    _this.tableData1.Picture_URL = Result.Picture_Url
                    _this.$message.success('上传成功')
                    console.log(Result.Picture_Url);
                  } else {
                    _this.$message.error('上传失败')
                  }
                },
                error: function () {
                  _this.$message.error("操作失败，请稍后再试")
                },
                dataType: "json"
              });
            }
          },
          error(err) {
            console.log(err.message);
          },
        });
      },
      handlePictureCardPreview(file) {
        this.dialogVisible = true
        this.dialogImageUrl = file
      },
      //删除图片
      handleRemove() {
        _this.tableData1.Picture_URL = ''
      },
    }
  })